From: Keir Fraser Date: Mon, 3 Nov 2008 13:36:24 +0000 (+0000) Subject: xentrace: Trace mmio/io read/write value X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~14054^2 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https://%22%22/%22http:/www.example.com/cgi/%22https:/%22%22?a=commitdiff_plain;h=4cd8a74f6e9e92a813bedba469975cf4b54892e0;p=xen.git xentrace: Trace mmio/io read/write value Signed-off-by: George Dunlap Signed-off-by: Keir Fraser --- diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index ae16db0dfc..1e583bc2dc 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -14,11 +14,39 @@ #include #include #include +#include #include #include #include #include +#define HVMTRACE_IO_ASSIST_WRITE 0x200 +static void hvmtrace_io_assist(int is_mmio, ioreq_t *p) +{ + unsigned int size, event; + unsigned char buffer[12]; + + if ( likely(!tb_init_done) ) + return; + + event = is_mmio ? TRC_HVM_MMIO_ASSIST : TRC_HVM_IO_ASSIST; + if ( !p->dir ) + event |= HVMTRACE_IO_ASSIST_WRITE; + + *(uint64_t *)buffer = p->addr; + size = (p->addr != (u32)p->addr) ? 8 : 4; + if ( size == 8 ) + event |= TRC_64_FLAG; + + if ( !p->data_is_ptr ) + { + *(uint32_t *)&buffer[size] = p->data; + size += 4; + } + + trace_var(event, 0/*!cycles*/, size, buffer); +} + static int hvmemul_do_io( int is_mmio, paddr_t addr, unsigned long *reps, int size, paddr_t ram_gpa, int dir, int df, void *p_data) @@ -111,6 +139,8 @@ static int hvmemul_do_io( p->data = value; p->io_count++; + hvmtrace_io_assist(is_mmio, p); + if ( is_mmio ) { rc = hvm_mmio_intercept(p); diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h index 5cce0287eb..5ca0657e0e 100644 --- a/xen/include/public/trace.h +++ b/xen/include/public/trace.h @@ -142,7 +142,9 @@ #define TRC_HVM_INVLPG64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x14) #define TRC_HVM_MCE (TRC_HVM_HANDLER + 0x15) #define TRC_HVM_IO_ASSIST (TRC_HVM_HANDLER + 0x16) +#define TRC_HVM_IO_ASSIST64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x16) #define TRC_HVM_MMIO_ASSIST (TRC_HVM_HANDLER + 0x17) +#define TRC_HVM_MMIO_ASSIST64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x17) #define TRC_HVM_CLTS (TRC_HVM_HANDLER + 0x18) #define TRC_HVM_LMSW (TRC_HVM_HANDLER + 0x19) #define TRC_HVM_LMSW64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x19)